Skip to content

feat: support enum split microflow statements#364

Open
hjotha wants to merge 2 commits intomendixlabs:mainfrom
hjotha:submit/microflow-enum-split-statement
Open

feat: support enum split microflow statements#364
hjotha wants to merge 2 commits intomendixlabs:mainfrom
hjotha:submit/microflow-enum-split-statement

Conversation

@hjotha
Copy link
Copy Markdown
Contributor

@hjotha hjotha commented Apr 27, 2026

Summary

Adds first-class MDL support for enumeration decision splits in microflows:

split enum $Status
  case Open, Pending
    return true;
  case (empty)
    return false;
  else
    return false;
end split;

Root Cause

The existing microflow model only had a boolean IF representation for exclusive splits. Studio Pro enumeration decisions are also exclusive splits, but their outgoing sequence flows carry EnumerationCase values. Without a dedicated MDL statement, describe/exec round-trips cannot preserve those case values cleanly.

Fix

  • Adds EnumSplitStmt and EnumSplitCase to the microflow AST.
  • Extends the grammar and visitor to parse split enum with multi-value cases and optional else.
  • Builds ExpressionSplitCondition graphs with EnumerationCase sequence flows.
  • Describes existing enum split graphs back to split enum syntax.
  • Updates validation, layout, terminality, reference walking, docs, skill guidance, and doctype examples.

Validation

  • go test ./mdl/visitor -run TestEnumSplit -count=1
  • go test ./mdl/executor -run 'Test(EnumSplit|TraverseFlow_EnumSplit|LastStmtIsReturn_EnumSplit|ValidateMicroflow_EnumSplit)' -count=1
  • ./bin/mxcli check mdl-examples/doctype-tests/enum_split_statement.test.mdl
  • make build
  • make lint-go
  • make test

Closes #347
Part of #332

Symptom: enumeration decision splits could not be represented as first-class MDL, so describe/exec round-trips either collapsed them into boolean-looking splits or lost the enumeration case structure.

Root cause: the microflow AST, parser, visitor, builder, describer, validator, and reference collectors only modeled boolean IF-style exclusive splits. Sequence flows with EnumerationCase values had no statement form.

Fix: add a split enum statement with case/else bodies, emit and parse enumeration case values, build ExpressionSplitCondition graphs with EnumerationCase flows, describe existing enum split graphs back to MDL, and teach validation/layout/terminality/reference walks to recurse through enum branches.

Tests: added parser, builder, describer, terminality, and validation regression tests plus a doctype fixture checked with mxcli check. Also ran make build, make lint-go, and make test.
Symptom: an enum split branch containing a nested empty-then decision could
round-trip to an MPR whose outgoing decision flow lacked the boolean case value,
causing Mendix mx check CE0079/CE0773 even when the described MDL was stable.

Root cause: addEnumSplit consumed flowBuilder.nextConnectionPoint from the
nested decision but dropped flowBuilder.nextFlowCase before wiring the branch
continuation to the shared enum merge.

Fix: carry the pending case value through enum branch continuation wiring and
reapply it when connecting to the next statement or enum merge.

Tests: add a builder regression for a nested empty-then enum branch that must
keep CaseValue=true on the continuation flow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve enum split microflow roundtrips

2 participants